package com.atguigu.commonutils.utils;

import cn.hutool.captcha.generator.RandomGenerator;

public class RandomUtils extends RandomGenerator {

    public RandomUtils(int count) {
        super(count);
    }

    public RandomUtils(String baseStr, int length) {
        super(baseStr, length);
    }

    /**
     * 生成指定长度的纯数字验证码
     */
    public static String numCode(int size){
        RandomGenerator randomGenerator = new RandomGenerator("0123456789", size);
        return randomGenerator.generate();
    }

    /**
     * 生成指定长度的纯字母验证码
     */
    public static String letterCode(int size){
        RandomGenerator randomGenerator = new RandomGenerator("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", size);
        return randomGenerator.generate();
    }

    /**
     * 生成指定长度的数字字母混合验证码
     */
    public static String mixCode(int size){
        RandomGenerator randomGenerator = new RandomGenerator("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", size);
        return randomGenerator.generate();
    }


}
